<?php
declare (strict_types = 1);

namespace app\business;

use think\Exception;
use think\facade\Log;

class ProductSpec {

    protected $model;

    public function __construct() {

        $this->model = new \app\model\mysql\ProductSpec();
    }

    /**
     * 获取规格列表
     *
     * @param string $field
     * @return array
     */
    public function getList($field = "id, name") : array {

        $specs = [];
        try{
            $specs = $this->model->getList($field);
        }catch (Exception $e){
            Log::error($e->getMessage());
        }

        return $specs;
    }

    public function isExist($id = 0) : bool {
        if ($id <= 0) {
            return false;
        }
        $isExist = false;
        try{
            $isExist = $this->model->isExist($id);
        }catch (Exception $e){
            Log::error($e->getMessage());
            return false;
        }

        return $isExist;
    }



}